
/**
 * 
 * 修改用户信息，选项卡
 * 
 * **/
function doOptions(meg){
	document.getElementById(meg).style.display = "block";	
	
	if(meg == 1){
		$("#2").css("display","none");
		$("#3").css("display","none");
		$("#jiben").removeClass("normal");
		$("#jiben").addClass("focus");
		$("#password").removeClass("focus");
		$("#password").addClass("normal");
		$("#addres").removeClass("focus");
		$("#addres").addClass("normal");
	}
	if(meg == 2)
	{
		$("#1").css("display","none");
		$("#3").css("display","none");
		$("#password").removeClass("normal");
		$("#password").addClass("focus");
		$("#addres").removeClass("focus");
		$("#addres").addClass("normal");
		$("#jiben").removeClass("focus");
		$("#jiben").addClass("normal");
	}
	if(meg == 3)
	{	
		$("#1").css("display","none");
		$("#2").css("display","none");
		$("#addres").removeClass("normal");
		$("#addres").addClass("focus");
		$("#jiben").removeClass("focus");
		$("#jiben").addClass("normal");
		$("#password").removeClass("focus");
		$("#password").addClass("normal");
	}
}
/**
 * @function 核对修改昵称
 * @returns {Boolean}
 */
function checkUserModifyNickname() {
	var userRegistNickname = $('#userRegistNickname').val();
	if(isEmpty(userRegistNickname)) {
		$('#userRegistNicknameError').html('<font style="color: red;">'+ErrorMsgConstants.ERR_INPUT_IS_NOT_ALLOW_NULL+'</font>');
		return false;
	}
	if(!validateInput(userRegistNickname, 2, 10, "0aAC")) {
		$('#userRegistNicknameError').html('<font style="color: red;">'+ErrorMsgConstants.ERR_USERNICKNAME_FORMAT_IS_NOT_VALID+'</font>');
		return false;
	}
	$('#userRegistNicknameError').html('<font style="color: green;">'+ValidMsgConstants.VALID_INPUT+'</font>');
	return true;
}
/**
 * 
 * 修改密码验证旧密码
 * 
 * */
function userModifyPassword(){
	var oldPassword = $('#userOldPassword').val();
	
	
	var flag = false;
	$.ajax({
		
			url: 'ajaxuserModifyPassword',
			data:{
				'userModifyPassword': oldPassword
			
				},
			type: 'post',
			async: false,
			dataType: 'json',
			success: function(res) {
					if(res){
						$('#userPassword').html('<font style="color: green;">'+ValidMsgConstants.VALID_INPUT+'</font>');
						flag = true;
					}
					else{
						$('#userPassword').html('<font style="color: red;">'+ErrorMsgConstants.ERR_PASSWORD_MODIFY+'</font>');
						flag =  false;
						
					}
				}
	});
	return flag;
}
/*
 * 验证地图地址
 * 
 * */
function checkModifyMapAddres(){
	var  map_x = $('#map_x').val();
	if(isEmpty(map_x))
		{
		$('#userModifyMapError').html('<font style="color: red;">'+ErrorMsgConstants.ERR_REGIST_MAP+'</font>');
		return false;
		}
		$('#userModifyMapError').html('<font style="color: green;">'+ValidMsgConstants.VALID_INPUT+'</font>');
	return true;
}
/**
 * @function 核对修改生日
 * @returns {Boolean}
 */
function checkUserModifyBirthday() {
	var userRegistBirthday = $('#userRegistBirthday').val();
	var regist = /^\d{4}-\d{2}-\d{2}$/;
	if(!(regist.test(userRegistBirthday)))
		{
		$('#userReRegistBirthdayError').html('<font style="color: red;">'+ErrorMsgConstants.ERR_REGIST_BIRTHDAY+'</font>');
		return false;
		}
	$('#userReRegistBirthdayError').html('<font style="color: green;">'+ValidMsgConstants.VALID_INPUT+'</font>');
	return true;
}

/**
 * @function 核对修改密码
 * @returns {Boolean}
 */
function checkUserModifyPassword() {
	var userRegistPassword = $('#userRegistPassword').val();
	if(isEmpty(userRegistPassword)) {
		$('#userRegistPasswordError').html('<font style="color: red;">'+ErrorMsgConstants.ERR_INPUT_IS_NOT_ALLOW_NULL+'</font>');
		return false;
	}
	if(!validateInput(userRegistPassword, 6, 10, "0aA")) {
		$('#userRegistPasswordError').html('<font style="color: red;">'+ErrorMsgConstants.ERR_USERPASSWORD_FORMAT_IS_NOT_VALID+'</font>');
		return false;
	}
	$('#userRegistPasswordError').html('<font style="color: green;">'+ValidMsgConstants.VALID_INPUT+'</font>');
	return true;
}
/*
 * 核对修改确认密码
 * 
 * */
function checkUserReModifyPassword() {
	var userRegistPassword = $('#userRegistPassword').val();
	var userReRegistPassword = $('#userReRegistPassword').val();
	
	if(isEmpty(userReRegistPassword)) {
		$('#userReRegistPasswordError').html('<font style="color: red;">'+ErrorMsgConstants.ERR_INPUT_IS_NOT_ALLOW_NULL+'</font>');
		
		return false;
	}
	if(userRegistPassword != userReRegistPassword) {
		$('#userReRegistPasswordError').html('<font style="color: red;">'+ErrorMsgConstants.ERR_USERREPASSWORD_IS_NOT_VALID+'</font>');
		$('#userReRegistPassword').val("");
		return false;
	}
	$('#userReRegistPasswordError').html('<font style="color: green;">'+ValidMsgConstants.VALID_INPUT+'</font>');
	return true;
}

/*
 * 
 * 
 * 修改资料标签01
 * 
 * */
function DoUpdate01(){
	
	var userModifyNickname = $('#userRegistNickname').val();
	var userModifyBirthday = $('#userRegistBirthday').val();
	var headUrl = $('#imgPath').val();
	var statement = $('#statement').val();
	
	if(checkUserModifyNickname() && checkUserModifyBirthday())	
		{
			$.ajax({
						url:'ajaxModify01',
						data:{
							'userModifyNickname' : userModifyNickname,
							'userModifyBirthday' : userModifyBirthday,
							'headUrl':headUrl,
							'statement':statement
							},
						type:'post',
						async: false,
						dataType:'json',
						success: function(res){
								if(res){
									
									CheckUpdateSuccess();
								}
								else{
									alert("false");
								}
							}
					});
		}
	else{
		
		CheckUpdateFalied();
		
	}
	
}
/*
 * 
 * 
 * 修改资料标签02
 * 
 * */
function DoUpdate02(){
	var userNewPassword = $('#userRegistPassword').val();
	
	if(userModifyPassword() && checkUserModifyPassword() && checkUserReModifyPassword()){
		
		$.ajax({
				url:'ajaxModify02',
				data:{
				
				 'userNewPassword':userNewPassword
					},
				type:'post',
				async: false,
				dataType:'json',
				success: function(res){
						if(res){
							CheckUpdateSuccess();
							
						}
						else{
							alert("false");
							
						}
					}
			});
			
	}
	else{
		
		CheckUpdateFalied();
	}
	
	
}
/*
 * 
 * 
 * 修改资料标签03
 * 
 * */
function DoUpdate03(){
	
	var mapX = $('#map_x').val();
	var mapY = $('#map_y').val();
	var mapAddr = $('#map_addr').val();                
	var mapProviderIdProperty = $('#map_provider').val();
	
	if(checkModifyMapAddres()){
		$.ajax({
			url:'ajaxAddFavorPosi',
			data:{
		
			 'mapX':mapX,
			 'mapY':mapY,
			 'mapAddr':mapAddr,
			 'mapProviderIdProperty':mapProviderIdProperty
				},
			type:'post',
			async: false,
			dataType:'json',
			success: function(res){
					if(res){
						CheckUpdateSuccess();
					}
					else{
						alert("false");
					}
				}
		});
		
	}
	else{
		CheckUpdateFalied();
	}
	
	
}

function ToUserInfoModifiy(){
	$("#outer").css("display",'none');
}
function ToMain(){
	window.close();
}
function UplaodImage(){
		
	$.ajax({
		url:"handleFormUpload",
		
		type:'post',
		async: false,
		dataType:'json',
		success: function(res){
			if(res.msg != null){
			window.document.location = "pictureUpload01";
	}
	}
	});
}
/*
 * 个性签名：
 * 
 * */
function checkStatement(){
	var len =  jQuery.trim($("#statement").val()).length;
	if(len < 0 || len > 30){
		return false;
	}
	return true;
}